<html>
<head><meta charset="utf-8"><title>negative bounds · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html">negative bounds</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216799290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216799290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216799290">(Nov 15 2020 at 15:53)</a>:</h4>
<p>How far along is chalk in support for negative bounds?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">RP</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">P</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">!</span><span class="n">RP</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Where <code>RP</code> and <code>P</code> are both traits I defined</p>



<a name="216799475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216799475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216799475">(Nov 15 2020 at 15:56)</a>:</h4>
<p>I needed this scenario because implementing <code>RP::bar</code> includes a lot of dependencies and thus I removed it from <code>P</code> and wanted to have a default implementation of it if <code>P</code> is implemented. But people might still want to define their own <code>RP::bar</code></p>



<a name="216800102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216800102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216800102">(Nov 15 2020 at 16:14)</a>:</h4>
<p>Hmm</p>



<a name="216800123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216800123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216800123">(Nov 15 2020 at 16:15)</a>:</h4>
<p>So, negative impls, IIRC, just prevent auto traits</p>



<a name="216800127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216800127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216800127">(Nov 15 2020 at 16:15)</a>:</h4>
<p>Or, are only really implemented for auto traits</p>



<a name="216800167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216800167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216800167">(Nov 15 2020 at 16:16)</a>:</h4>
<p>But, not in the negative reasoning since</p>



<a name="216800195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216800195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216800195">(Nov 15 2020 at 16:17)</a>:</h4>
<p>I didn't understand what you said, sorry</p>



<a name="216801400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216801400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216801400">(Nov 15 2020 at 16:42)</a>:</h4>
<p>Negative impls in where clauses aren't implemented</p>



<a name="216801411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216801411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216801411">(Nov 15 2020 at 16:42)</a>:</h4>
<p>only things like <code>impl !Send for Foo {}</code></p>



<a name="216876817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/216876817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#216876817">(Nov 16 2020 at 14:21)</a>:</h4>
<p>negative bounds are "kind of" supported in chalk, but they are meant for specialized purposes; I do not think we will ever add them to rust because they make everything more complicated</p>



<a name="217062597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/negative%20bounds/near/217062597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/negative.20bounds.html#217062597">(Nov 17 2020 at 21:05)</a>:</h4>
<p>this sounds like specialization...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>